package com.qianfeng.smsplatform.api.service.impl;/***
 *                    .::::.
 *                  .::::::::.
 *                 :::::::::::  
 *             ..:::::::::::'   木马~
 *           '::::::::::::'       
 *             .::::::::::       
 *        '::::::::::::::..
 *             ..::::::::::::.
 *           ``::::::::::::::::
 *            ::::``:::::::::'        .:::.
 *           ::::'   ':::::'       .::::::::.
 *         .::::'      ::::     .:::::::'::::.
 *        .:::'       :::::  .:::::::::' ':::::.
 *       .::'        :::::.:::::::::'      ':::::.
 *      .::'         ::::::::::::::'         ``::::.
 *  ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 *                    '.:::::'                    ':'````..
 */

import com.qianfeng.smsplatform.api.service.PushSubmitToQueueService;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：zl
 * @date ：Created in 2021/7/17 20:05
 */
@Service
public class PushSubmitToQueueServiceImpl implements PushSubmitToQueueService {

    private AmqpTemplate amqpTemplate;

    @Autowired
    public void setAmqpTemplate(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }



    //发送数据到mq
    @Override
    public void sendSubmitToQueue(List<Standard_Submit> standard_submitList) {
        //每一个手机号对应的短信要一条一条发送,而不是作为一个整体发送短信, 所以此处进行了分拆,拆分后挨个发送
        standard_submitList.forEach(submit->{
            amqpTemplate.convertAndSend(RabbitMqConsants.TOPIC_PRE_SEND,submit);
        });
    }
}
